# Macros para o compilador
CC = gcc 
CFLAGS = -ansi
DBGFLAGS = -g3 -Wall
OPTFLAGS = -O3
OBJFLAGS = -c
OUTFLAGS = -o

# Macros de diretórios
SRCDIR = src/
TSTDIR = src/tst/
BINDIR = bin/
OBJDIR = bin/obj/
DBGDIR = bin/dbg/

# Macros de arquivos
OBJECTS = $(OBJDIR)client.o $(OBJDIR)server.o $(OBJDIR)ping.o
SOURCES = $(SRCDIR)client.c $(SRCDIR)server.c $(SRCDIR)pingudp.h $(SRCDIR)ping.c
TESTS = 

all: $(SOURCES)
	$(CC) $(CFLAGS) $(OPTFLAGS) $(SRCDIR)client.c $(OUTFLAGS) $(BINDIR)client
	$(CC) $(CFLAGS) $(OPTFLAGS) $(SRCDIR)server.c $(OUTFLAGS) $(BINDIR)server
	$(CC) $(CFLAGS) $(OPTFLAGS) $(SRCDIR)ping.c $(OUTFLAGS) $(BINDIR)ping

debug: $(OBJECTS)
	$(CC) $(OBJDIR)client.o $(OUTFLAGS) $(DBGDIR)client
	$(CC) $(OBJDIR)server.o $(OUTFLAGS) $(DBGDIR)server
	$(CC) $(OBJDIR)ping.o $(OUTFLAGS) $(DBGDIR)ping

test: 

clean:

$(OBJDIR)%.o: $(SRCDIR)%.c
	$(CC) $(CFLAGS) $(DBGFLAGS) $(OBJFLAGS) $< $(OUTFLAGS) $@